package com.walker.elk.netty.heartbeat.client;

import java.util.concurrent.TimeUnit;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.string.StringDecoder;
import io.netty.handler.codec.string.StringEncoder;
import io.netty.handler.timeout.IdleStateHandler;

public class HeartBeatClientChannelInitializer extends ChannelInitializer<SocketChannel> {

	@Override
	protected void initChannel(SocketChannel channel) throws Exception {
		
		ChannelPipeline channelPipeline = channel.pipeline();
		
		channelPipeline.addLast("idleStateHandler", new IdleStateHandler(0, 3, 0, TimeUnit.SECONDS));
		
		channelPipeline.addLast("decoder", new StringDecoder());
		
		channelPipeline.addLast("encoder", new StringEncoder());
		
		channelPipeline.addLast(new HeartBeatClientChannelHandler());
	}

}
